package com.wltjack.springboot.common;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.stereotype.Component;

/**
 * 	自定义的健康指标，功能更强大，AbstractHealthIndicator实现了HealthIndicator接口
 * <p>
 * 	实例见：DataSourceHealthIndicator，RedisHealthIndicator
 * </p>
 */
@Component("myHealthIndicatorSecond")
public class MyHealthIndicatorSecond extends AbstractHealthIndicator {
	private static final String VERSION = "v1.0.0";

	@Override
	protected void doHealthCheck(Builder builder) throws Exception {
		int code = 0;
		if(code != 0) {
			builder.down().withDetail("code", code).withDetail("version", VERSION).build();
		}
		builder.up().withDetail("code", code).withDetail("version", VERSION).build();
	}
	
	

}
